#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e5+1000;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL c[maxn],d[maxn];
int main(void){
   cin.tie(0);std::ios::sync_with_stdio(false);
   LL t;cin>>t;
   while(t--){
      LL n,l,r;cin>>n>>l>>r;
      memset(c,0,sizeof(c));
      memset(d,0,sizeof(d));

      for(LL i=1;i<=l;i++){
          LL x;cin>>x;
          c[x]++;
      }
      for(LL i=1;i<=r;i++){
          LL x;cin>>x;
          d[x]++;
      }


      if(l>=r){
         LL ans=0;
         for(LL i=1;i<=n;i++){
             if(c[i]>d[i]){
                LL p=min( (c[i]-d[i])/2,(l-r)/2);
                ans+=p;
                d[i]+=p;
                c[i]-=p;
                l-=p;
                r+=p;
             }
         }
         for(LL i=1;i<=n;i++){
             if(c[i]>d[i]){
                LL p=min(c[i]-d[i],l-r);
                ans+=p;
                d[i]+=p;
                c[i]-=p;
                l-=p;
                r+=p;
             }
         }
         LL cnt=0;
         for(LL i=1;i<=n;i++){
            cnt+=abs(c[i]-d[i]);
         }
         ans+=cnt/2;
         cout<<ans<<"\n";
      }
      else{
         LL sum=0;
         for(LL i=1;i<=n;i++){
             if(d[i]>c[i]){
                LL k=min((d[i]-c[i])/2,(r-l)/2);
                sum+=k;
                c[i]+=k;d[i]-=k;
                r-=k;l+=k;
             }
         }
         for(LL i=1;i<=n;i++){
              if(d[i]>c[i]){
                 LL k=min(d[i]-c[i],r-l);
                 sum+=k;
                 d[i]-=k;
                 c[i]+=k;
                 r-=k;
                 l+=k;
              }
         }
         LL cnt=0;
         for(LL i=1;i<=n;i++){
             cnt+=abs(d[i]-c[i]);
         }
         sum+=cnt/2;
         cout<<sum<<"\n";
      }
   }
   return 0;
}
